package com.hhj.king.provider.ctrl;

import com.hhj.king.provider.entity.Person;
import com.hhj.king.provider.srv.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author KING
 * @date 2018/9/22 18:25
 */
@RestController
public class ProviderController {

    @Value("${hello.king:你好啊}")
    private String king;
    @Autowired
    private PersonService personService;

    @RequestMapping(value = "/person/{providerId}")
    public String sayHello(@PathVariable("providerId") String providerId, HttpServletRequest req) {
        Person p = personService.findById(providerId);
        p.setMsg(req.getRequestURL().toString());
        return p.toString();
    }
}
